package com.sgcc.ln.pmos.e_ln_home.presenter;


import com.sgcc.ln.pmos.common.base.BasePresenter;
import com.sgcc.ln.pmos.common.http.HttpInterConst;
import com.sgcc.ln.pmos.common.http.HttpRequestUtils;
import com.sgcc.ln.pmos.common.http.MvpNetCallback;
import com.sgcc.ln.pmos.common.utils.ListPageUtil;
import com.sgcc.ln.pmos.e_ln_home.bean.DynamicBean;
import com.sgcc.ln.pmos.e_ln_home.bean.DynamicNetBean;
import com.sgcc.ln.pmos.e_ln_home.contract.PoliciesRegulationsContract;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.Call;


public class PoliciesRegulationsPresenter extends BasePresenter<PoliciesRegulationsContract.View> implements PoliciesRegulationsContract.Presenter {

    public void getListData(int pageSize) {
        Map<String, Object> params = new HashMap<>();
        params.putAll(ListPageUtil.getPageInfo(pageSize));
        params.put("_t", System.currentTimeMillis());

        HttpRequestUtils.getInstance().request(params, HttpInterConst.HOME_MARKETDAYNAMICS, new MvpNetCallback<DynamicNetBean>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                // 失败回调 判断界面是否销毁
                if (!isViewAttached()) {
                    return;
                }
            }

            @Override
            public void onResponse(DynamicNetBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().queryNetDataSuccess(response);
            }
        });
    }
}
